package com.itheima.controller;

import com.itheima.common.MessageConst;
import com.itheima.entity.Result;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户控制器
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/findAll.do")
    public Result add(){
        log.info("[用户-查询所有]……");
        // 调用service添加数据
        List<User> users =   userService.findAll();
        return new Result(true, MessageConst.ACTION_SUCCESS,users);
    }
}
